﻿using UnityEngine;
using System.Collections;
using System.IO;
using System.Text;
using System;

namespace ZXthex.Html
{
    public class HtmlDocument
    {

        ReadOnlyHtmlNode root, head, body;

        public Encoding Encoding { get; private set; }

        public ReadOnlyHtmlNode Root { get { return root; } }

        public ReadOnlyHtmlNode Head { get { return head; } }

        public ReadOnlyHtmlNode Body { get { return body; } }

        public void LoadFrom(string path)
        {
            using (var reader = NextChars.FromFile(path))
            {
                BuildDocument(reader);
            }
        }

        public void LoadHtml(string html)
        {
            using (var reader = NextChars.FromString(html))
            {
                BuildDocument(reader);
            }
        }

        void BuildDocument(NextChars reader)
        {
            HtmlDocumentBuilder.Default.LoadHtml(reader, out root, out head, out body);

        }


    }



}